package com.cjw.controller.operationAnalysis;

import com.cjw.pojo.dto.operationAnalysis.BarDTO;
import com.cjw.service.operationAnalysis.CommunityService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

/**
 * @author : cjw
 * @date: : 2022/3/11 20:46
 * @description : 社区活跃度controller
 */
@RestController
@RequestMapping("/admin/community")
@Api("生活分享评论资源")
public class CommunityController {

    @Autowired
    private CommunityService communityService;
    // 评论数、计划参与数、生活分享发布数，点赞数，收藏数、计划发布数、朗读发布数
    @GetMapping("/share")
    @ApiOperation("生活折线图")
    public List<List> share(@RequestParam(value = "date", required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date date) {
        if (date == null)
            date = new Date();
        return communityService.share(date);
    }

    @GetMapping("/plan")
    @ApiOperation("计划饼状图")
    public List<BarDTO> plan(@RequestParam(value = "date", required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date date) {
        if (date == null)
            date = new Date();
        return communityService.plan(date);
    }

    @GetMapping("/read")
    @ApiOperation("朗读直方图")
    public List<BarDTO> read(@RequestParam(value = "date", required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date date) {
        if (date == null)
            date = new Date();
        return communityService.read(date);
    }
}
